/**
 * Created by Mexios on 04/08/14.
 * Validation formulaire Connexion.
 */

var app = angular.module('estim',['ngAnimate']);
app.controller('ConnexionCtrl',function($scope,$http) {
    var $form = document.forms['formConnexion'];
    $scope.formInfo = {};
    $scope.saveData = function() {

        var animationIn ='animated flipInX';
        var animationOut ='animated flipOutX';

        if (!$scope.loginCon) {
            $scope.loginRequired = 'login requis';
            $('#logError').removeClass(animationOut);
            $('#logError').addClass(animationIn);
        }else{
            $('#logError').removeClass(animationIn);
            $('#logError').addClass(animationOut);
            $scope.loginRequired = '';
        }

        if (!$scope.mdpCon) {
            $scope.mdpRequired = 'mot de passe requis';
            $('#logError').removeClass(animationOut);
            $('#logError').addClass(animationIn);
        }else{
            $('#logError').removeClass(animationIn);
            $('#logError').addClass(animationOut);
            $scope.mdpRequired = '';
        }


        if ((!$scope.loginCon) || (!$scope.mdpCon)) {
            $scope.valueRequired = 'Remplissez les champs manquants';
        } else {
            $scope.valueRequired = '';
            $form.submit();
        }

    return false;
    };
});